﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Packaging;
using OPCDiffCore.Text;
using OPCDiffCore.Binaries;
using OPCDiffCore.XML;
using OPCDiffCore.Relationship;

namespace OPCDiffCore
{
    internal abstract class PartAnalyzer
    {
        internal abstract PartDiff Analyze(PackagePart originalPart, PackagePart diffPart, AnalyzeLevel level);

        /// <summary>
        /// Gets the appropriate analyzer for the specified part.
        /// </summary>
        /// <param name="originalPart">The part to analyze.</param>
        /// <returns>Either a text based analyzer or a binary based analyzer according to
        /// the content type of the specified part.</returns>
        internal static PartAnalyzer GetAnalyzer(PackagePart originalPart)
        {
            if (Utils.IsTextPart(originalPart))
                return new TextAnalyzer();
            else if (Utils.IsXmlPart(originalPart))
                //return new XmlAnalyzer();
                return new TextAnalyzer();
            else if (Utils.IsRelationshipPart(originalPart))
                return new RelationshipAnalyzer();
            else
                return new BinaryAnalyzer();
        }
    }
}
